#容器类型  -- python中内置的数据结构
#
#list -- 列表
#1、有序项目集合
#2、可变数据类型
#3、存放任何数据类型

#列表的定义：
# lst = []
# type(lst)
# Out[3]: list
# lst2 = list()
# type(lst2)
# Out[5]: list
# lst3 = list("abc")   #工厂函数，它可以把其他数据类型转换成list。 传递可迭代对象（能被for遍历的）
# lst3
# Out[7]: ['a', 'b', 'c']

#有序项目集合
# lst = ["a", "b", "c", "d", "e"]
# lst[1]
# Out[9]: 'b'
# lst[-1]
# Out[10]: 'e'
# lst[-1:2:-2]
# Out[11]: ['e']

#可变数据类型
#在原内存地址空间上，可以修改的，就是可变数据类型
# lst = ["ab", "123"]
# id(lst)
# Out[13]: 2283404262784
# lst[1] = "xxyy"
# id(lst)
# Out[15]: 2283404262784
# lst
# Out[16]: ['ab', 'xxyy']
# str1 = "abc"
# str1[1] = "x"
# Traceback (most recent call last):
#   File "D:\python38\lib\site-packages\IPython\core\interactiveshell.py", line 3397, in run_code
#     exec(code_obj, self.user_global_ns, self.user_ns)
#   File "<ipython-input-18-48f418600765>", line 1, in <cell line: 1>
#     str1[1] = "x"
# TypeError: 'str' object does not support item assignment

#存放任何数据类型
# lst = ["a", 3.4, 4, [1], print]
# lst
# Out[20]: ['a', 3.4, 4, [1], <function print>]

#############
#新增 -- append 在末尾添加一个元素
# lst = ["aa","12", "bb"]
# lst.append("xxx")
# lst
# Out[23]: ['aa', '12', 'bb', 'xxx']
# lst.append([1,2])
# lst
# Out[25]: ['aa', '12', 'bb', 'xxx', [1, 2]]

# -- insert 指定位置插入
# lst
# Out[25]: ['aa', '12', 'bb', 'xxx', [1, 2]]
# lst.insert(2, "***")
# lst
# Out[27]: ['aa', '12', '***', 'bb', 'xxx', [1, 2]]

# -- extend   传递进去的元素是可迭代对象
# lst
# Out[28]: ['aa', '12', '***', 'bb', 'xxx', [1, 2]]
# lst.extend("qwer")
# lst
# Out[30]: ['aa', '12', '***', 'bb', 'xxx', [1, 2], 'q', 'w', 'e', 'r']
# lst.extend(10)
# Traceback (most recent call last):
#   File "D:\python38\lib\site-packages\IPython\core\interactiveshell.py", line 3397, in run_code
#     exec(code_obj, self.user_global_ns, self.user_ns)
#   File "<ipython-input-31-48c22eeaeb4f>", line 1, in <cell line: 1>
#     lst.extend(10)
# TypeError: 'int' object is not iterable

#列表的运算 可以相加 可以相乘
# lst = [1,2]
# lst2 = [3,4]
# lst + lst2
# Out[34]: [1, 2, 3, 4]
# result = lst + lst2
# result
# Out[36]: [1, 2, 3, 4]
# lst * 3
# Out[37]: [1, 2, 1, 2, 1, 2]

################删除
# lst = ["a", "b", 1, 2, "c", "d"]
# lst.pop()
# Out[40]: 'd'
# result = lst.pop()
# result
# Out[42]: 'c'
# lst.pop(2)
# Out[43]: 1
# lst.remove("b")
# result
# Out[45]: 'c'
# lst
# Out[46]: ['a', 2]
# lst = ["a", "b", "c", "d", "e"]
# lst[2:]
# Out[48]: ['c', 'd', 'e']
# del lst[2:]
# lst
# Out[50]: ['a', 'b']
# lst.clear()
# lst
# Out[52]: []

##############修改
# lst = ["a", "b", "c", "d", "e", "f"]
# lst[3] = "xxx"
# lst
# Out[56]: ['a', 'b', 'c', 'xxx', 'e', 'f']
# lst[2:5]
# Out[57]: ['c', 'xxx', 'e']
# lst[2:5] == "abc"
# Out[58]: False
# lst
# Out[59]: ['a', 'b', 'c', 'xxx', 'e', 'f']
# lst[2:5] = "abc"  #切片修改， 赋值对象是一个可迭代对象
# lst
# Out[61]: ['a', 'b', 'a', 'b', 'c', 'f']

######统计类
# lst
# Out[62]: ['a', 'b', 'a', 'b', 'c', 'f']
# len(lst)
# Out[63]: 6
# lst.count("a")
# Out[64]: 2
# lst.index("a")
# Out[65]: 0

#######copy属性
# Out[66]: ['a', 'b', 'a', 'b', 'c', 'f']
# lst2 = lst
# lst2[1] = "***"
# lst2
# Out[69]: ['a', '***', 'a', 'b', 'c', 'f']
# lst
# Out[70]: ['a', '***', 'a', 'b', 'c', 'f']
# id(lst)
# Out[71]: 2283422233216
# id(lst2)
# Out[72]: 2283422233216
# lst3 = lst.copy()
# lst3
# Out[74]: ['a', '***', 'a', 'b', 'c', 'f']
# lst
# Out[75]: ['a', '***', 'a', 'b', 'c', 'f']
# lst3[1] = "yyy"
# lst3
# Out[77]: ['a', 'yyy', 'a', 'b', 'c', 'f']
# lst
# Out[78]: ['a', '***', 'a', 'b', 'c', 'f']
# lst[:]
# Out[79]: ['a', '***', 'a', 'b', 'c', 'f']
# lst4 = lst[:]
# lst4[1] = "ppp"
# lst4
# Out[82]: ['a', 'ppp', 'a', 'b', 'c', 'f']
# lst
# Out[83]: ['a', '***', 'a', 'b', 'c', 'f']


##############反转和排序
# lst.reverse()
# lst
# Out[86]: ['f', 'c', 'b', 'a', '***', 'a']
# lst.sort()
# lst
# Out[88]: ['***', 'a', 'a', 'b', 'c', 'f']
# lst.sort(reverse = True)
# lst
# Out[90]: ['f', 'c', 'b', 'a', 'a', '***']

#############成员关系判断
# lst
# Out[91]: ['f', 'c', 'b', 'a', 'a', '***']
# "f" in lst
# Out[92]: True
# "f" not in lst
# Out[93]: False

#列表的遍历
# lst = ["abc", "aa", "xx", "xyz"]
#
# for i in lst:
#     print(i)
#
# for k,v in enumerate(lst):
#     print(f"{k} -- > {v}")

#lst=[3,5,1,6,7,34, 9,2, 6, 8]
#从键盘输入一个数， 10  --》3+7  --》0， 4

#一条船30个人，超载  最多载15个人。
#把30个人进行编号，数到第8个就下船，最后输出哪些人下船了
# lst = []
# out = []
# count = 0
# v = 0 #记录列表的下标
# #编号
# for i in range(1, 31):
#     lst.append(i)
# print(f"编号{lst}")
# while count < 15:
#     for i in range(0, 7):
#         if v >= len(lst)-1:
#             v = 0
#         else:
#             v = v + 1
#     out.append(lst[v])
#     lst.pop(v)
#     count = count + 1
#
# print(f"下船的人的编号为{out}")

#
lst = list( range(1,31) )
print("编号:", lst)
while len(lst) > 15:
    for i in range(7):
        lst.append(lst.pop(0))
    print(f"下船的人为:{lst.pop(0)}")

#牛客、PAT 刷算法题
#github上找一些小项目练习
#leetcode

